package org.greatstorm.dao.impl;

import java.util.List;

import org.greatstorm.dao.GeneralDao;
import org.greatstorm.dao.TagArticleRelationDao;
import org.greatstorm.entity.EntityObject;
import org.greatstorm.entity.TagArticleRelation;
import org.greatstorm.util.Filter;
import org.greatstorm.util.Operator;

public class TagArticleRelationDaoImpl extends GeneralDao implements
		TagArticleRelationDao {

	@Override
	protected String getEntityName() {
		return "tagarticlerelation";
	}

	@Override
	public void removeRelationByArticleKey(String artKey) {
		Filter f = new Filter();
		f.setKey(TagArticleRelation.ARTICLE_KEY);
		f.setOpt(Operator.OPT_EQUAL);
		f.setValue(artKey);

		List<EntityObject> ret = this.getEntityListByFilter(f);

		for (EntityObject o : ret) {
			this.delete(o.getKey());
		}
	}

}
